﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO.IsolatedStorage;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FastestWays.Model;

namespace FastestWays.Server
{
    class SettingsEngine
    {
        public const string LocationServiceOnSettingFromIsoKey = "LocationServiceOnSettingFromIso";
        public void LoadIsLocationServiceOnSettingFromIso()
        {
            if (IsolatedStorageSettings.ApplicationSettings.Any() && IsolatedStorageSettings.ApplicationSettings.Contains(LocationServiceOnSettingFromIsoKey))
            {
                Parameters.IsLocationServiceOn = (bool)IsolatedStorageSettings.ApplicationSettings[LocationServiceOnSettingFromIsoKey];
            }
            else
            {
                Parameters.IsLocationServiceOn = true;
            }
        }

        public void SaveIsLocationServiceOnSettingToIso()
        {
            if (IsolatedStorageSettings.ApplicationSettings.Contains(LocationServiceOnSettingFromIsoKey))
            {
                IsolatedStorageSettings.ApplicationSettings[LocationServiceOnSettingFromIsoKey] =
                    Parameters.IsLocationServiceOn;
            }
            else
            {
                IsolatedStorageSettings.ApplicationSettings.Add(LocationServiceOnSettingFromIsoKey, Parameters.IsLocationServiceOn);                
            }
        }
    }
}
